﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication6
{
    public partial class Regist : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = TextBox1.Text;
            string password = TextBox2.Text;
            int gender = RadioButton1.Checked ? 0 : 1;
            string email = TextBox3.Text;

            string sql = "server=LAPTOP-KBF70ACQ;uid=sa;password=2324ln;databsse=Student_db";
            SqlParameter[] pars =
            {
                new SqlParameter("name",name),
                new SqlParameter("gender",gender),
                new SqlParameter("email",email),
                new SqlParameter("password",password)
            };
            SQLHelper helper = new SQLHelper();
            int result = helper.Add(sql, pars);
            if (result!=-1)
            {
                Literal1.Text = "注册成功！<a href=\"Login.aspx\">点此去登陆</a>";
            }

        }

    }
}